home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / hardware / blizkick / modules / prepareemul.asm < prev    next >
Assembly Source File  |  1999-05-17  |  2KB  |  89 lines

  1. ; FILE: Source:modules/PrepareEmul.ASM          REV: 18 --- PrepareEmul for BlizKick
  2.  
  3. ;
  4. ; PrepareEmul patch for BlizKick ("patch" Module)
  5. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ; Written by Harry Sintonen.
  7. ; This source code is Public Domain.
  8. ;
  9. ; Original PrepareEmul belongs to The ShapeShifter package
  10. ; © Copyright 1993-1997 Christian Bauer. This patch doesn't really
  11. ; base on PrepareEmul program, but ShapeShifter's documentation...
  12. ;
  13.  
  14.     incdir    "include:"
  15.     include    "blizkickmodule.i"    ; Some required...
  16.  
  17.     SECTION    PATCH,CODE
  18. _DUMMY_LABEL
  19.     BK_PTC
  20.  
  21. ; Code is run with following incoming parameters:
  22. ;
  23. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  24. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  25. ; d0=ROM lenght in bytes    eg. $00080000
  26. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  27. ;    CALL: jsr (a2)
  28. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  29. ;     OUT: d0=ptr to resident (buf) or NULL
  30. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  31. ;    CALL: jsr (a3)
  32. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  33. ;     OUT: d0=success
  34. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  35. ;    CALL: jsr (a4)
  36. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  37. ;     OUT: -
  38. ; d6=dosbase, a6=execbase
  39. ;
  40. ; Code should return:
  41. ;
  42. ; d0=true if succeeded, false if failed.
  43. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  44.  
  45. NEWSTART    EQU    $2000
  46.  
  47.     moveq    #0,d7
  48.     lsr.l    #1+5,d0            ; d0=1st 1/32th of the rom (words)
  49.     move.w    #$41F8,d2        ; cmp preload
  50.     move.l    #$210843F8,d3        ; -""-
  51. .find    subq.l    #1,d0
  52.     beq.b    .done
  53.     move.l    (a0),d1
  54.     addq.l    #2,a0
  55.     cmp.w    d1,d2
  56.     beq.b    .lea_a0
  57.     cmp.l    d1,d3
  58.     bne.b    .find
  59. .lea_a0    addq.l    #2,a0
  60.     cmp.w    #$3000,(a0)        ; A1200 rom!
  61.     IFEQ    NEWSTART-$3000
  62.     beq.b    .skip
  63.     ELSE
  64.     beq.b    .is
  65.     ENDC
  66.     cmp.w    #$0400,(a0)
  67.     beq.b    .is
  68.     cmp.w    #$1000,(a0)
  69.     bne.b    .find
  70. .is    move.w    #NEWSTART,(a0)
  71. .skip    addq.l    #1,d7
  72.     bra.b    .find
  73.  
  74. .done    move.l    d7,d0
  75.     bne.b    .exitok
  76.     lea    (.errmsg,pc),a0
  77.     jsr    (a4)
  78.     moveq    #0,d0
  79. .exitok    rts
  80.  
  81.  
  82. .errmsg    dc.b    'This ROM isn''t compatible with PrepareEmul patch!',10,0
  83.  
  84.  
  85.     SECTION    VERSION,DATA
  86.  
  87.     dc.b    '$VER: PrepareEmul_PATCH 1.4 (30.5.97)',0
  88.  
  89.